package nz.ac.massey.se.Q6;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.List;

import org.junit.*;

/**
 * Testing Q6.B
 *
 * @author Charles Zheng
 * @id 19029962
 */


public class TestClass {
    static List<Course> courses;
    Course SE;

    @BeforeClass
    public static void setUpClass() throws Exception {
        courses = new ArrayList<Course>();
        System.out.println("setUpClass()");
    }

    @AfterClass
    public static void releaseClass() throws Exception {
        courses.clear();
        System.out.println("releaseClass()");
    }

    @Before
    public void setUp() throws Exception {
        SE = new Course("SE", 159251);
        courses.add(SE);
        System.out.println("setUp()");
    }

    @After
    public void tearDown() throws Exception {
        SE.clearEnrolment();
        System.out.println("tearDown()");
    }

    @Test
    public void testEnrolment() {
        Student tom = new Student("Bob", 123456);
        Student jack = new Student("Sarah", 123457);
        SE.addStudent(tom);
        SE.addStudent(jack);
        System.out.println("testEnrolment");
        assertEquals(SE.getTotalStudents(), 2);
        assertEquals(SE.getStudent(123456).getName(), "Bob");
        assertEquals(SE.getStudent(123457).getName(), "Sarah");
    }
}
